﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using Rhino.Mocks;
using System.Web.Security;
using Ashlen.Portal.Core;
using Ashlen.Portal.Data.SqlServer;
using Ashlen.Portal.Core.DataInterfaces;
using Ashlen.Portal.Core.DTO;

namespace Ashlen.Portal.Tests.Ashlen.Portal.CoreTests
{
    [TestFixture]
    public class MembershipTest
    {
        public MembershipProvider Provider
        {
            get;
            private set;
        }
        private readonly ISecurityDao _securityDao;

        public MembershipTest()
        {
            Provider = Membership.Provider;
            _securityDao = new SecurityDao();            
        }

        [SetUp]
        public void SetUp()
        {
        }

        [Test]
        public void InsertAvatar()
        {
            MembershipUser user = Provider.GetUser("shailen", true);
            var info = _securityDao.GetPersonalInfo((user != null ? new Guid(user.ProviderUserKey.ToString()) : default(Guid))) as aspnet_UserPersonalInfo;
            Bitmap img = new Bitmap(@"..\..\images\Shailen.jpg");
            System.IO.MemoryStream outStream = new System.IO.MemoryStream();
            img.Save(outStream, ImageFormat.Jpeg);

            info.Avatar = outStream.ToArray();
            _securityDao.SaveAvatar(new Guid(user.ProviderUserKey.ToString()), info.Avatar);
            /*_securityDao.CreatePersonalInfo(new Guid(user.ProviderUserKey.ToString()), info.Firstname, info.Lastname,
                                                        info.Nickname,
                                                        info.DateOfBirth, info.Sex, info.Mobile, info.Phone,
                                                        info.Country, info.State, info.Postcode, System.Guid.NewGuid().ToString(),
                                                        false, true);*/

        }
    }
}
